#include <iostream>
#include <signal.h>
#include <unistd.h>

void signal_handler(int sig)
{
    std::cout << "recieve a signal: " << sig << std::endl;
    sleep(1);
}

int main()
{
    signal(SIGFPE, signal_handler);
    signal(SIGSEGV, signal_handler);
    //signal(SIGINT, signal_handler);

    std::cout << "This is a process, pid:" << getpid() << std::endl;

    // int a = 100;
    // int b = a / 0;

    int *pa = nullptr;
    *pa = 10;  // 野指针问题

    while(true) {}

    return 0;
}